﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace GXRTBTC.PublicClassLibrary.Model
{
    /// <summary>
    /// 告警跳变类
    /// 告警跳变规则
    /// </summary>
    public class AlarmRules
    {
        /// <summary>
        /// 规则ID
        /// </summary>
        public string ruleId { get; set; } = "0";
        /// <summary>
        /// 3级转2级，是否启用
        /// </summary>
        public bool t2 { get; set; } = false;
        /// <summary>
        /// 3级转2级，持续分钟数
        /// </summary>
        public int t2t { get; set; } = 0;
        /// <summary>
        /// 2级转3级，是否启用
        /// </summary>
        public bool t1 { get; set; } = false;
        /// <summary>
        /// 2级转3级，持续分钟数
        /// </summary>
        public int t1t { get; set; } = 0;

        /// <summary>
        /// 检查是否需要跳变
        /// 0不需要，大于0代表需要，且返回的就是跳变分钟数
        /// </summary>
        /// <param name="alarmLevel"></param>
        /// <returns></returns>
        public int GetAddTime(int alarmLevel)
        { 
            //to time
            int tt = 0;
            switch (alarmLevel)
            {
                case 3:
                    tt = (t2 && t2t > 0) ? t2t : 0;
                    break;
                case 2:
                    tt = (t1 && t1t > 0) ? t1t : 0;
                    break;
                default:  break;
            }

            return tt;
        }
    }
}
